package com.wg.dome;

import com.wg.common.ioc.WgIoc;
import com.wg.db.service.SyncWriteService;
import com.wg.dome.chat.ChatLobby;
import com.wg.game.BaseGameApplication;
import com.wg.net.BasePeer;
import com.wg.net.operations.InitRequest;

import java.net.InetSocketAddress;

public class DomeApplication extends BaseGameApplication {
    private SyncWriteService writeService;
    private TestRpcPeer rpcPeer;

    @Override
    protected BasePeer createPeer(InitRequest initRequest) {
        return new ClientPeer(initRequest, this);
    }

    @Override
    protected String getAppName() {
        return "dome";
    }

    @Override
    protected void onStart() {
        writeService = WgIoc.get(SyncWriteService.class);
        writeService.start();
        rpcPeer = new TestRpcPeer(this);
        //rpcPeer.connect(new InetSocketAddress("192.168.1.10", 8000), "testrpc", null);
    }

    @Override
    protected void onStop() {
        writeService.stop();
        rpcPeer.close();
    }

    public ChatLobby getChatLobby() {
        return WgIoc.get(ChatLobby.class);
    }
}
